<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>

    <script>
        // 问题1:JavaScript 中 undefined 和 not defined 的区别
        /* var x;
        console.log(x); //x = undefined 

        console.log(typeof y);   //output: undefined

        console.log(z); // 抛出异常: ReferenceError: z is not defined
 */

        var y = 1;
        if (function f(){}) {
            y += typeof f;
        }
        console.log(y);


        /*
         * 作用域问题
        */
        var a = 10;
        function test(){
            console.log(a);
            a = 100;
            console.log(a);
            console.log(this.a);
            var a;
            console.log(a);
        };
        test();
        console.log(a);

    </script>
</body>
</html>